package com.ktgj.customer.common;

import com.alibaba.fastjson.JSONArray;
import com.ktgj.customer.common.HeydayUtils;
import com.ktgj.customer.domain.Insurance.HeyDayInsuranceVo;
import com.ktgj.customer.domain.Insurance.heydayModel.HeydayUrlInfo;

import java.net.URLEncoder;

public class heydayTest
{
    public static void main(String[] args) {
        HeydayUtils heydayUtils = new HeydayUtils();

        HeyDayInsuranceVo heyDayInsuranceVo = new HeyDayInsuranceVo();
        heyDayInsuranceVo.setStartTime("2022-07-29 19:00");
        heyDayInsuranceVo.setArriveTime("2022-07-30 07:00");
        heyDayInsuranceVo.setStartPosition("北京");
        heyDayInsuranceVo.setDestination("上海");
        heyDayInsuranceVo.setTransportNum("MU1234");
        heyDayInsuranceVo.setPhName("李博洋");
        heyDayInsuranceVo.setPhIdType("1");
        heyDayInsuranceVo.setPhIdNo("231182200010260536");
        heyDayInsuranceVo.setPhPhone("18745654372");
        heyDayInsuranceVo.setPhEmail("851523157@qq.com");

        HeydayUrlInfo heydayUrlInfo = null;
        try {
            String type = "train";
            heydayUrlInfo = heydayUtils.heydayInsurance(type);
        } catch (Exception e){
            e.printStackTrace();
        }

        String json = JSONArray.toJSON(heyDayInsuranceVo).toString();

        String encode = null;
        try {
            encode = URLEncoder.encode(json, "utf-8");
        } catch (Exception e){
            System.out.println("encodeURI转码失败");
        }

        if (heydayUrlInfo.getUrl() != null && encode != null){
            String url = heydayUrlInfo.getUrl() + "&extend=" + encode;
//            String url = heydayUrlInfo.getUrl() + "&extend=" + json;
            System.out.println(url);
        }
        else {
            System.out.println("-------------");
        }
    }
}
